Skip to content

feat(sdk): add triggerConfig support to chat.headStart()#3916

Closed
saasjesus wants to merge 1 commit into
triggerdotdev:mainfrom
saasjesus:feat/chat-headstart-trigger-config
Closed

feat(sdk): add triggerConfig support to chat.headStart()#3916
saasjesus wants to merge 1 commit into
triggerdotdev:mainfrom
saasjesus:feat/chat-headstart-trigger-config

Conversation

@saasjesus

Copy link
Copy Markdown
Contributor

Summary

  • Adds optional triggerConfig to chat.headStart() and chat.openSession(), threading it through openHandoverSession into createSession.
  • Merges customer trigger options (tags, queue, machine, maxAttempts, maxDuration, region, lockToVersion) the same way as chat.createStartSessionAction(), auto-prepending chat:{chatId} to tags.
  • Top-level idleTimeoutInSeconds still wins over triggerConfig.idleTimeoutInSeconds; handover-prepare trigger and chatId in basePayload cannot be overridden by customer config.

Test plan

  • cd packages/trigger-sdk && pnpm test src/v3/chat-server.test.ts --run
  • New test asserts merged tags (chat:chat-1 first) and queue on createSession
  • Manual: configure chat.headStart({ triggerConfig: { tags, queue } }) and verify handover-prepare run appears with expected tags/queue in dashboard

Made with Cursor

Handover-prepare session runs now accept the same tags, queue, and
session trigger options as chat.createStartSessionAction(), with
chat:{chatId} auto-prepended to tags.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: df96c66

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@trigger.dev/sdk Patch
@trigger.dev/python Patch
@internal/sdk-compat-tests Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/plugins Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
trigger.dev Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a83c91cb-c9d3-4983-acec-75a0a9853c24

📥 Commits

Reviewing files that changed from the base of the PR and between de8231c and df96c66.

📒 Files selected for processing (3)
  • .changeset/chat-headstart-trigger-config.md
  • packages/trigger-sdk/src/v3/chat-server.test.ts
  • packages/trigger-sdk/src/v3/chat-server.ts

Walkthrough

This PR adds optional triggerConfig support to the chat.headStart() and chat.openSession() APIs. Handlers can now pass trigger options like tags, queue, machine type, and other session-level settings. The implementation merges caller-provided configuration with handover-prepare requirements, automatically prepends a chat:<chatId> tag (capped to 5 total), and constructs a final SessionTriggerConfig sent to session creation. Tests verify tag merging, queue preservation, and correct basePayload rewriting.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 14 UNAVAILABLE: read ECONNRESET


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @saasjesus, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Jun 12, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

opts.idleTimeoutInSeconds ?? opts.triggerConfig?.idleTimeoutInSeconds ?? 60;

const userTags = opts.triggerConfig?.tags ?? [];
const tags = [`chat:${chatId}`, ...userTags].slice(0, 5);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Tag limit discrepancy: headStart uses 5 (correct), createStartSessionAction uses 10 (pre-existing issue)

The new headStart code at packages/trigger-sdk/src/v3/chat-server.ts:340 truncates tags with .slice(0, 5), which correctly matches the SessionTriggerConfig schema at packages/core/src/v3/schemas/api.ts:1577 (.max(5)). However, the analogous createStartSessionAction at packages/trigger-sdk/src/v3/ai.ts:9714 uses .slice(0, 10) with a comment saying "Platform cap is 10 tags per run" — that 10-tag cap applies to CreateSessionRequestBody.tags (line 1615), not triggerConfig.tags. If a customer passes >4 user tags through createStartSessionAction, the server would reject the request due to schema validation. The headStart code is the correct one; the pre-existing createStartSessionAction has a latent bug for users with many tags.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant